<template>
    <div>111111111111</div>
    <mi-form-page @submit="submit"
                  title="商城信息"
                  v-model:show="edit.show"
                  :loading="edit.loading"
                  showType="page"
                  noBack
    >
        <el-form :model="edit.info"
                 :rules="rules"
                 ref="formRef">

            <el-form-item prop="title" label="名称">
                <mi-input v-model="edit.info.title"/>
            </el-form-item>
            <el-form-item prop="logo" label="网站logo">
                <mi-up-image v-model="edit.info.logo"/>
            </el-form-item>
            <el-form-item prop="icon" label="网站图标">
                <mi-up-image v-model="edit.info.icon" :size="48" />
            </el-form-item>

            <el-form-item prop="phone" label="客服电话">
                <mi-input v-model="edit.info.phone"/>
            </el-form-item>

            <el-form-item prop="title" label="地址">
                <mi-select-address :info="edit.info" />
            </el-form-item>
            <el-form-item prop="status" label="状态">
                <mi-switch v-model="edit.info.status"/>
            </el-form-item>

        </el-form>
    </mi-form-page>
</template>

<script setup lang="ts">
import {ref, onBeforeMount, reactive} from "vue";
import {FormInstance} from "element-plus";
import Edit from "@/model/edit";
import {useAdminStore} from "@/store/admin";
import {simplePost} from "@/utils/request";
import {msgSuccess} from "@/utils/alert";

const adminStore = useAdminStore()

const edit = reactive(new Edit({
    show:true,
    info:adminStore.site,
}))
const rules = {
    title:[{required:true, message:'必填'}],
}

const formRef = ref<FormInstance>()

const submit = () => {
    formRef.value?.validate( (valid,fields) => {
        if (valid){
            simplePost("/sys.config/siteInfoEdit", edit.info).then(res => {
                msgSuccess("保存成功")
            })
        }

    })

}



</script>

<style scoped>

</style>
